<?php
	

class modSimpleYoutubeList{

	// Retrieves one Random Video
	function getOne($list){

		// filter input to ensure same
		$list = str_replace("http://",'',$list);
		$list = str_replace("www.",'',$list);
		$list = str_replace("/watch?v=",'',$list);
		// remove, in case user put in
		$list = str_replace("/v/",'',$list);
		

		// now, turn into array
		$vids = explode("youtube.com",$list);

		// remove blank entries
		foreach($vids as $key => $value) { 
			if($value == "") unset($vids[$key]); 
		} 

		// return random video ID from array
		return $vids[array_rand($vids)];
	}

}

?>
